/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.webhomesites.padrao.utils;

import java.math.RoundingMode;
import java.text.NumberFormat;

/**
 *
 * @author Webhome
 */
public class FormatadorNumeros {
    
    public double formatarDouble(Double vlr) {
        NumberFormat format = NumberFormat.getInstance();  
        format.setMaximumFractionDigits(2);  
        format.setMinimumFractionDigits(2);  
        format.setMaximumIntegerDigits(5);  
        format.setRoundingMode(RoundingMode.HALF_EVEN);
        String valor;
        valor = Double.toString(vlr);
        return Double.parseDouble(valor.equals("")?"0":(valor.contains(".")?valor.replace(".", "").replace(",", "."):valor.replace(",",".")));
    }    
}
